import React, {Component} from 'react';
import T from 'prop-types'

import { Menu, Dropdown } from 'antd';

import { WeaLocaleProvider } from "ecCom";
const getLabel = WeaLocaleProvider.getLabel;

export default class Mood extends Component {
    constructor(props) {
        super(props)
        this.state = {
            visible: false,
            value:""
        }
    }


    componentDidMount(){
         const  mooddata = this.props.mooddata;
         if(mooddata&&mooddata.value!=""){
             this.setState({value:mooddata.value});
         }

    }

    render() {
        let {visible, value} = this.state;
        return (
            <Dropdown ecId={`${this && this.props && this.props.ecId || ''}_Dropdown@ej1192`} trigger={['click']} onVisibleChange={this.onVisibleChange} overlay={
                <Menu ecId={`${this && this.props && this.props.ecId || ''}_Menu@pf57rf`} onSelect={this.onMoodSelect}>
                    <Menu.Item ecId={`${this && this.props && this.props.ecId || ''}_undefined@93mz5f`} key="1">
                        <span className="icon-blog-Emoji">&nbsp;{getLabel(26917,"高兴")}</span>
                    </Menu.Item>
                    <Menu.Item ecId={`${this && this.props && this.props.ecId || ''}_undefined@nojggb`} key="2">
                        <span className="icon-blog-Unhappy">&nbsp;{getLabel(26918,"不高兴")}</span>
                    </Menu.Item>
                </Menu>
            }>
                <div className="wea-cb-item">
                    <span className={"wea-cbi-icon "+(value === "2" ? "icon-blog-Unhappy": "icon-blog-Emoji")}/>
                    <span className="wea-cbi-text">{getLabel(26769,"心情")}</span>
                </div>
            </Dropdown>
        )
    }
	
	getValue(){
		return this.state.value
	}

    onVisibleChange = (value) =>{
        this.setState({visible: value})
    }

    onMoodSelect = (item) => {
    	const { onSelect } = this.props;
        this.setState({value: item.key});
        typeof onSelect === 'function' && onSelect(item.key)
    }
}
